package com.my.study.aop;

import com.my.study.aop.config.AopConfig;
import com.my.study.aop.jdk.JDKProxy;
import com.my.study.aop.jdk.UserDao;
import com.my.study.aop.jdk.UserDaoImpl;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author Carlos
 * @version 1.0
 * @Description test类
 * @date 2021/11/5 8:58
 **/
public class AopTest {

    @Test
    public void testJDK() {

        JDKProxy jdkProxy = new JDKProxy(new UserDaoImpl());
        UserDao target = (UserDao) jdkProxy.getTarget();
        int add = target.add(1, 2);
        System.out.println(add);
    }

    @Test
    public void testAspects() {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AopConfig.class);

        MathCalculator mathCalculator = context.getBean(MathCalculator.class);
        mathCalculator.div(1, 1);

        context.close();
    }

}
